#include "../Headers/day03.h"

myString ::myString(const char *p_new)
{
    this->len = strlen(p_new) + 1;
    // p =(char *)calloc(len+1,1);
    this->p = new char[this->len];
    strcpy(this->p, p_new);
    cout << this << endl;
}
myString ::myString(const myString &str)
{
    this->len = str.len;
    this->p = new char[len];
    strcpy(this->p, str.p);
}
myString ::~myString()
{
    cout << __LINE__ << ":" << __func__ << endl;
    delete[] this->p;
    this->p = NULL;
}
void myString ::show()
{
    cout << this->p << endl;
}
char myString ::getval(int offset)
{
    return *(this->p + offset);
    // return this->p[offset];
}
// stu

int stu::age = 10;
string stu ::name = "hhh";
char stu::msg[12] = {};
int stu::x = 100;
stu ::stu(string name, int age, char *p, int xxx)
{
    this->x = x;
    strncpy(this->msg, p, 12);
    this->name = name;
    this->age = age;
}
stu ::~stu()
{
}
void stu::show()
{
    cout << stu::age << endl;
    cout << stu::name << endl;
    cout << stu::msg << endl;
    cout << stu::x << endl;
}
void stu ::fun()
{
    cout << "static func" << endl;
}
//////////const
const_test ::const_test(int a, int b, int c) : a(a), b(b)
{
    this->c = c;
}
const_test :: ~const_test(){}

void const_test::show()
{
    cout << const_test::a << endl;
    cout << const_test::b << endl;
    cout << const_test::c << endl;
    const_test::c = 1000;
    cout << const_test::c << endl;
}

void const_test ::fun() const
{
    cout << const_test::a << endl;
    cout << const_test::b << endl;
    cout << const_test::c << endl;
}

A:: A(){
    this->a = 100;
}
A::~A(){}
void A:: fun(){}
void test(){
    A a1;
    cout <<a1.a<<endl;
}
B:: B(){
    
    cout <<this->a3.a <<endl;
}
B::~B(){}
void B ::class_friend(){
    cout <<a3.a<< endl;
}
